import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    tabbar: {
      active: 0,
      isShow: false
    },
    city: localStorage.city || '北京'
  },
  mutations: {
    changeTabbarActive: function (state, value) {
      state.tabbar.active = value
    },
    changeTabbarState: function (state, status) {
      state.tabbar.isShow = status
    },
    changeCity: function (state, value) {
      state.city = value
      localStorage.city = value
    }
  },
  actions: {
    changeTabbarActive: function (context, value) {
      context.commit('changeTabbarActive', value)
    },
    changeTabbarState: function (context, status) {
      context.commit('changeTabbarState', status)
    },
    changeCity: function (context, value) {
      context.commit('changeCity', value)
    }
  }
})
